package com.neusoft.data.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.neusoft.data.domain.SerChatHistory;
import com.neusoft.data.service.ISerChatHistoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 聊天记录Controller
 * 
 * @author slh
 * @date 2024-03-14
 */
@RestController
@RequestMapping("/courseSelect/chatHistory")
public class SerChatHistoryController extends BaseController
{
    @Autowired
    private ISerChatHistoryService serChatHistoryService;

    /**
     * 查询聊天记录列表
     */
    @PreAuthorize("@ss.hasPermi('courseSelect:chatHistory:list')")
    @GetMapping("/list")
    public TableDataInfo list(SerChatHistory serChatHistory)
    {
        startPage();
        List<SerChatHistory> list = serChatHistoryService.selectSerChatHistoryList(serChatHistory);
        return getDataTable(list);
    }

    /**
     * 导出聊天记录列表
     */
    @PreAuthorize("@ss.hasPermi('courseSelect:chatHistory:export')")
    @Log(title = "聊天记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SerChatHistory serChatHistory)
    {
        List<SerChatHistory> list = serChatHistoryService.selectSerChatHistoryList(serChatHistory);
        ExcelUtil<SerChatHistory> util = new ExcelUtil<SerChatHistory>(SerChatHistory.class);
        util.exportExcel(response, list, "聊天记录数据");
    }

    /**
     * 获取聊天记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('courseSelect:chatHistory:query')")
    @GetMapping(value = "/{chatId}")
    public AjaxResult getInfo(@PathVariable("chatId") Long chatId)
    {
        return success(serChatHistoryService.selectSerChatHistoryByChatId(chatId));
    }

    /**
     * 新增聊天记录
     */
    @PreAuthorize("@ss.hasPermi('courseSelect:chatHistory:add')")
    @Log(title = "聊天记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SerChatHistory serChatHistory)
    {
        return toAjax(serChatHistoryService.insertSerChatHistory(serChatHistory));
    }

    /**
     * 修改聊天记录
     */
    @PreAuthorize("@ss.hasPermi('courseSelect:chatHistory:edit')")
    @Log(title = "聊天记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SerChatHistory serChatHistory)
    {
        return toAjax(serChatHistoryService.updateSerChatHistory(serChatHistory));
    }

    /**
     * 删除聊天记录
     */
    @PreAuthorize("@ss.hasPermi('courseSelect:chatHistory:remove')")
    @Log(title = "聊天记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{chatIds}")
    public AjaxResult remove(@PathVariable Long[] chatIds)
    {
        return toAjax(serChatHistoryService.deleteSerChatHistoryByChatIds(chatIds));
    }
}
